{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "看到类似 __ slots __ 这种形如 __ xxx __ 的变量或者函数名就要注意，这些在Python中是有特殊用途的。\n",
    "\n",
    "__ slots __ 我们已经知道怎么用了，__ len __ ()方法我们也知道是为了能让class作用于len()函数。\n",
    "\n",
    "除此之外，Python的class中还有许多这样有特殊用途的函数，可以帮助我们定制类。\n",
    "\n",
    " # __ str __"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们先定义一个Student类，打印一个实例："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<__main__.Student object at 0x0000028CA96DEA88>\n"
     ]
    }
   ],
   "source": [
    "class Student(object):\n",
    "    def __init__(self, name):\n",
    "        self.name = name\n",
    "print(Student('Michael'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "打印出一堆< __ main __ .Student object at 0x109afb190>，不好看。\n",
    "\n",
    "怎么才能打印得好看呢？只需要定义好 __ str __ ()方法，返回一个好看的字符串就可以了："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Student object (name: Michael)\n"
     ]
    }
   ],
   "source": [
    "class Student(object):\n",
    "    def __init__(self, name):\n",
    "        self.name = name\n",
    "    def __str__(self):\n",
    "        return 'Student object (name: %s)' % self.name\n",
    "\n",
    "print(Student('Michael'))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这样打印出来的实例，不但好看，而且容易看出实例内部重要的数据。\n",
    "\n",
    "但是细心的朋友会发现直接敲变量不用print，打印出来的实例还是不好看："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<__main__.Student at 0x28ca970af48>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = Student('Michael')\n",
    "s"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这是因为直接显示变量调用的不是 __ str __ ()，而是 __ repr __ ()，两者的区别是 __ str __ ()返回用户看到的字符串，而 __ repr __ ()返回程序开发者看到的字符串，也就是说，__ repr __ ()是为调试服务的。\n",
    "\n",
    "解决办法是再定义一个 __ repr __ ()。但是通常 __ str __ ()和 __ repr __ ()代码都是一样的，所以，有个偷懒的写法："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Student(object):\n",
    "    def __init__(self, name):\n",
    "        self.name = name\n",
    "    def __str__(self):\n",
    "        return 'Student object (name=%s)' % self.name\n",
    "    __repr__ = __str__"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# __ iter __\n",
    "如果一个类想被用于for ... in循环，类似list或tuple那样，就必须实现一个 __ iter __ ()方法，该方法返回一个迭代对象，然后，Python的for循环就会不断调用该迭代对象的 __ next __ ()方法拿到循环的下一个值，直到遇到StopIteration错误时退出循环。\n",
    "\n",
    "我们以斐波那契数列为例，写一个Fib类，可以作用于for循环："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Fib(object):\n",
    "    def __init__(self):\n",
    "        self.a, self.b = 0, 1 # 初始化两个计数器a，b\n",
    "\n",
    "    def __iter__(self):\n",
    "        return self # 实例本身就是迭代对象，故返回自己\n",
    "\n",
    "    def __next__(self):\n",
    "        self.a, self.b = self.b, self.a + self.b # 计算下一个值\n",
    "        if self.a > 100000: # 退出循环的条件\n",
    "            raise StopIteration()\n",
    "        return self.a # 返回下一个值"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "现在，试试把Fib实例作用于for循环："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "1\n",
      "2\n",
      "3\n",
      "5\n",
      "8\n",
      "13\n",
      "21\n",
      "34\n",
      "55\n",
      "89\n",
      "144\n",
      "233\n",
      "377\n",
      "610\n",
      "987\n",
      "1597\n",
      "2584\n",
      "4181\n",
      "6765\n",
      "10946\n",
      "17711\n",
      "28657\n",
      "46368\n",
      "75025\n"
     ]
    }
   ],
   "source": [
    "for n in Fib():\n",
    "    print(n)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# __ getitem __\n",
    "Fib实例虽然能作用于for循环，看起来和list有点像，但是，把它当成list来使用还是不行，比如，取第5个元素："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'Fib' object is not subscriptable",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-7-14290f619470>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mFib\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: 'Fib' object is not subscriptable"
     ]
    }
   ],
   "source": [
    "Fib()[5]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "要表现得像list那样按照下标取出元素，需要实现 __ getitem __ ()方法："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Fib(object):\n",
    "    def __getitem__(self, n):\n",
    "        a, b = 1, 1\n",
    "        for x in range(n):\n",
    "            a, b = b, a + b\n",
    "        return a"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "现在，就可以按下标访问数列的任意一项了："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f= Fib()\n",
    "f[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f[3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "89"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f[10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "573147844013817084101"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f[100]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "但是list有个神奇的切片方法："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[5, 6, 7, 8, 9]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(100))[5:10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "对于Fib却报错。原因是 __ getitem __ ()传入的参数可能是一个int，也可能是一个切片对象slice，所以要做判断："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Fib(object):\n",
    "    def __getitem__(self, n):\n",
    "        if isinstance(n, int): # n是索引\n",
    "            a, b = 1, 1\n",
    "            for x in range(n):\n",
    "                a, b = b, a + b\n",
    "            return a\n",
    "        if isinstance(n, slice): # n是切片\n",
    "            start = n.start\n",
    "            stop = n.stop\n",
    "            if start is None:\n",
    "                start = 0\n",
    "            a, b = 1, 1\n",
    "            L = []\n",
    "            for x in range(stop):\n",
    "                if x >= start:\n",
    "                    L.append(a)\n",
    "                a, b = b, a + b\n",
    "            return L"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "再试试Fib的切片："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 1, 2, 3, 5]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f = Fib()\n",
    "f[0:5]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "但是没有对step参数作处理："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "f[:10:2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "也没有对负数作处理，所以，要正确实现一个 __ getitem __ ()还是有很多工作要做的。\n",
    " \n",
    "此外，如果把对象看成dict，__ getitem __ ()的参数也可能是一个可以作key的object，例如str。\n",
    "\n",
    "与之对应的是 __ setitem __ ()方法，把对象视作list或dict来对集合赋值。最后，还有一个 __ delitem __ ()方法，用于删除某个元素。\n",
    "\n",
    "总之，通过上面的方法，我们自己定义的类表现得和Python自带的list、tuple、dict没什么区别，这完全归功于动态语言的“鸭子类型”，不需要强制继承某个接口。\n",
    " # __ getattr __\n",
    " 正常情况下，当我们调用类的方法或属性时，如果不存在，就会报错。比如定义Student类："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Student(object):\n",
    "    \n",
    "    def __init__(self):\n",
    "        self.name = 'Michael'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "调用name属性，没问题，但是，调用不存在的score属性，就有问题了："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Michael\n"
     ]
    }
   ],
   "source": [
    "s = Student()\n",
    "print(s.name)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'Student' object has no attribute 'score'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-23-b28ac891daed>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mscore\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m: 'Student' object has no attribute 'score'"
     ]
    }
   ],
   "source": [
    "print(s.score)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "错误信息很清楚地告诉我们，没有找到score这个attribute。\n",
    "\n",
    "要避免这个错误，除了可以加上一个score属性外，Python还有另一个机制，那就是写一个 __ getattr __ ()方法，动态返回一个属性。修改如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Student(object):\n",
    "\n",
    "    def __init__(self):\n",
    "        self.name = 'Michael'\n",
    "\n",
    "    def __getattr__(self, attr):\n",
    "        if attr == 'score':\n",
    "            return 99"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "当调用不存在的属性时，比如score，Python解释器会试图调用 __ getattr __ (self, 'score')来尝试获得属性，这样，我们就有机会返回score的值："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "99"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = Student()\n",
    "s.score"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "返回函数也是完全可以的："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Student(object):\n",
    "\n",
    "    def __getattr__(self, attr):\n",
    "        if attr == 'age':\n",
    "            return lambda: 25"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "只是调用方式要变为："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "25"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = Student()\n",
    "s.age()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "注意，只有在没有找到属性的情况下，才调用 __ getattr __ ，已有的属性，比如name，不会在 __ getattr __ 中查找。\n",
    "\n",
    "此外，注意到任意调用如s.abc都会返回None，这是因为我们定义的 __ getattr __ 默认返回就是None。要让class只响应特定的几个属性，我们就要按照约定，抛出AttributeError的错误："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Student(object):\n",
    "\n",
    "    def __getattr__(self, attr):\n",
    "        if attr=='age':\n",
    "            return lambda: 25\n",
    "        raise AttributeError('\\'Student\\' object has no attribute \\'%s\\'' % attr)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这实际上可以把一个类的所有属性和方法调用全部动态化处理了，不需要任何特殊手段。\n",
    "\n",
    "这种完全动态调用的特性有什么实际作用呢？作用就是，可以针对完全动态的情况作调用。\n",
    "\n",
    "举个例子：\n",
    "\n",
    "现在很多网站都搞REST API，比如新浪微博、豆瓣啥的，调用API的URL类似：\n",
    "\n",
    "- http://api.server/user/friends\n",
    "- http://api.server/user/timeline/list\n",
    "\n",
    "如果要写SDK，给每个URL对应的API都写一个方法，那得累死，而且，API一旦改动，SDK也要改。\n",
    "\n",
    "利用完全动态的 __ getattr __ ，我们可以写出一个链式调用："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Chain(object):\n",
    "\n",
    "    def __init__(self, path=''):\n",
    "        self._path = path\n",
    "\n",
    "    def __getattr__(self, path):\n",
    "        return Chain('%s/%s' % (self._path, path))\n",
    "\n",
    "    def __str__(self):\n",
    "        return self._path\n",
    "\n",
    "    __repr__ = __str__"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "试试："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    " Chain().status.user.timeline.list"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这样，无论API怎么变，SDK都可以根据URL实现完全动态的调用，而且，不随API的增加而改变！\n",
    "\n",
    "还有些REST API会把参数放到URL中，比如GitHub的API："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "GET /users/:user/repos"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "调用时，需要把:user替换为实际用户名。如果我们能写出这样的链式调用："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "Chain().users('michael').repos"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# __ call __\n",
    "一个对象实例可以有自己的属性和方法，当我们调用实例方法时，我们用instance.method()来调用。能不能直接在实例本身上调用呢？在Python中，答案是肯定的。\n",
    "\n",
    "任何类，只需要定义一个 __ call __ ()方法，就可以直接对实例进行调用。请看示例："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Student(object):\n",
    "    def __init__(self, name):\n",
    "        self.name = name\n",
    "\n",
    "    def __call__(self):\n",
    "        print('My name is %s.' % self.name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "调用方式如下"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "My name is Michael.\n"
     ]
    }
   ],
   "source": [
    "s = Student('Michael')\n",
    "s() # self参数不要传入"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "__ call __ ()还可以定义参数。对实例进行直接调用就好比对一个函数进行调用一样，所以你完全可以把对象看成函数，把函数看成对象，因为这两者之间本来就没啥根本的区别。\n",
    "\n",
    "如果你把对象看成函数，那么函数本身其实也可以在运行期动态创建出来，因为类的实例都是运行期创建出来的，这么一来，我们就模糊了对象和函数的界限。\n",
    "\n",
    "那么，怎么判断一个变量是对象还是函数呢？其实，更多的时候，我们需要判断一个对象是否能被调用，能被调用的对象就是一个Callable对象，比如函数和我们上面定义的带有 __ call __ ()的类实例："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "callable(Student('Michael'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    " callable(max)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "callable([1, 2, 3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "callable(None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "callable('str')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "通过callable()函数，我们就可以判断一个对象是否是“可调用”对象。\n",
    "# 小结\n",
    "Python的class允许定义许多定制方法，可以让我们非常方便地生成特定的类。\n",
    "\n",
    "本节介绍的是最常用的几个定制方法，还有很多可定制的方法，请参考Python的官方文档。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
